<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0, minimum-scale=1.0, user-scalable=0, initial-scale=1.0, width=device-width" />
    <meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
    <title>TMP工单</title>
    <link rel="stylesheet" type="text/css" href="../css/mui.min.css" />
    <link rel="stylesheet" type="text/css" href="../css/common.css" />
    <link rel="stylesheet" href="../css/page_css/util.css">
    <style type="text/css">
        .mui-card-footer .mui-card-link {
            font-size: 12px;
            height: 35px;
            line-height: 35px;
        }

        .mui-table-view-cell.line:after,
        .mui-table-view.line:after {
            height: 0;
        }

        .mui-checkbox input[type=checkbox]:before {
            font-size: 24px;
        }

        .title_ {
            color: #333333;
            font-weight: bold;
        }

        .detail {
            padding-right: 20px!important;
        }
        .abnormals_span{
          display: inline-block;
          border-radius: 50%;
          width: 20px;
          height: 20px;
          text-align: center;
          line-height: 20px;
          color: #fff;
          background-color: red
        }
        .noneTopLine:before {
            height: 0!important;
        }
        .bgc_ccc{
          background-color: #ccc !important;
          border-color: #ccc !important ;
        }
        .mui-table-view::before{
          height: 0;
        }
        .mui-table-view-cell.mui-collapse .mui-table-view .mui-table-view-cell{
          padding-right: 31px;
        }
        .mui-table-view-cell::before{
          height: 0;
        }
        .content-padded_top > .mui-table-view > .mui-table-view-cell{
          padding: 0 15px;
        }
        .mui-card-footer::before{
          height: 0;
        }
        .mui-radio input[type=radio]{
          top:-4px !important;
        }
        .text_right{
          text-align: right;
        }
        .padding_15{
          padding: 15px !important;
        }
        .list > .mui-table-view-cell > ul > .mui-table-view-cell{
          padding-top: 3px !important;
          padding-bottom: 3px !important;
        }
        .list > .mui-table-view-cell > ul > .mui-table-view-cell:after{
          height: 0 !important;
        }
        .list > .mui-table-view-cell > ul > .mui-table-view-cell .mui-card-footer{
          padding-top: 0 !important;
          padding : 0 !important;
          min-height: 24px !important;
        }
        .list > .mui-table-view-cell > ul > .mui-table-view-cell .mui-card-footer::before{
          height: 0 !important;
        }
        .list > .mui-table-view-cell > ul > .mui-table-view-cell .mui-card-footer label{
          font-size: 12px !important;
          min-width: 98px;
          text-align: left;
          padding-right: 0 !important;
        }
        .list > .mui-table-view-cell > ul > .mui-table-view-cell .mui-card-footer .mui-radio input[type=radio]{
          top:0 !important;
        }
        .list > .mui-table-view-cell > ul > .mui-table-view-cell .mui-card-footer .mui-radio input[type=radio]::before{
          font-size: 24px;
        }
        .color_1{
          color: #11d7a4;
        }
        .color_2{
          color: #6264f8;
        }
        .flex{
        }
        .clearfloat:after{display:block;clear:both;content:"";visibility:hidden;height:0}
        .clearfloat{zoom:1}
        .flex > li{
          /*float: left;*/
        }
        .upload_img{
          width: 40px;
          height: 40px;
        }
        .padding_5{
          padding: 5px;
        }
        .li_style{
          border-radius: 10px;
          margin-bottom: 10px;
          list-style:none
        }
        .no_border::after{
          height: 0 !important;
        }
        .no_padding{
          padding: 0 !important;
        }
        .no_margin{
          margin: 0 !important
        }
    </style>
</head>

<body>
    <div class="mui-content content-padded_top">
        <ul class="mui-table-view">
            <li class="mui-table-view-cell line">
                <div class="mui-table">
                	 <p>TIS附件：</p>
                    <ul class="mui-table-view mui-table-view-chevron line" >
                        <li class="mui-table-view-cell" id='ul_img' >
                          <script type="text/temmlate" id="tmpImgList">
                           <!--   {{each datas as item}}
                                <img class="mui-media-object" src="{{item.src}}" tapmode onclick="showRemotePicture(baseURL + 'downloadFile?docinfoid='+'{{item.docinfoid}}', '{{item.description}}')" />
                              {{/each}}-->

                              {{each datas as item}}
								<li class="mui-table-view-cell" onclick='uploadXlsx("{{item.docinfoid}}", "{{item.description}}")'>
									<span class="mui-h5">{{item.description}}</span>
								</li>
							{{/each}}
                          </script>
                        </li>
                    </ul>
                </div>
            </li>
        </ul>
        <div class="mui-content-padded fixed_btn_top">
            <ul class="mui-table-view mui-table-view-chevron">
                <li class="mui-table-view-cell detail">
                    <div class="mui-table">
                        <div class="mui-table-cell mui-col-xs-4">
                            <h5 class="mui-ellipsis">工单号：</h5>
                        </div>
                        <div class="mui-table-cell mui-col-xs-8 mui-text-right">
                            <span class="mui-h5" id='workorderid'></span>
                        </div>
                    </div>
                </li>
                <li class="mui-table-view-cell detail">
                    <div class="mui-table">
                        <div class="mui-table-cell mui-col-xs-4">
                            <h5 class="mui-ellipsis">工单名称：</h5>
                        </div>
                        <div class="mui-table-cell mui-col-xs-8 mui-text-right">
                            <span class="mui-h5" id='description'></span>
                        </div>
                    </div>
                </li>
                <li class="mui-table-view-cell detail">
                    <div class="mui-table">
                        <div class="mui-table-cell mui-col-xs-4">
                            <h5 class="mui-ellipsis">位置：</h5>
                        </div>
                        <div class="mui-table-cell mui-col-xs-8 mui-text-right">
                            <span class="mui-h5" id='location'></span>
                        </div>
                    </div>
                </li>
                <!--<li class="mui-table-view-cell detail">
                    <div class="mui-table">
                        <div class="mui-table-cell mui-col-xs-4">
                            <h5 class="mui-ellipsis">实际开始时间：</h5>
                        </div>
                        <div class="mui-table-cell mui-col-xs-8 mui-text-right">
                            <span class="mui-h5" id='actstart'></span>
                        </div>
                    </div>
                </li>
                <li class="mui-table-view-cell detail">
                    <div class="mui-table">
                        <div class="mui-table-cell mui-col-xs-4">
                            <h5 class="mui-ellipsis">实际结束时间：</h5>
                        </div>
                        <div class="mui-table-cell mui-col-xs-8 mui-text-right">
                            <span class="mui-h5" id='actfinish'></span>
                        </div>
                    </div>
                </li>-->
                <li class="mui-table-view-cell detail">
                    <div class="mui-table">
                        <div class="mui-table-cell mui-col-xs-4">
                            <h5 class="mui-ellipsis">关联工单号：</h5>
                        </div>
                        <div class="mui-table-cell mui-col-xs-8 mui-text-right">
                            <span class="mui-h5" id='wonum'></span>
                        </div>
                    </div>
                </li>
            </ul>
            <div class="fixed_btn_group">
                <button class="mui-btn mui-btn-primary" id="start_btn" onclick="onStart(this)">开始</button>
                <button class="mui-btn mui-btn-success bgc_ccc" id="suspend_btn" onclick='onSuspend(this)'>暂停</button>
                <button type="button" class="mui-btn mui-btn-warning bgc_ccc" id="end_btn" onclick='onEnd(this)'>结束</button>
            </div>
            <div class="mui-table-view-cell">
              <span class="mui-h5" id='timer'></span>
            </div>
        </div>
        <div id='tmpDiv' class="mui-card">
            <!-- 模板引擎 -->
        </div>
    </div>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script src="../script/mui.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../script/common.js" type="text/javascript" charset="utf-8"></script>
<script src="../script/template.js" type="text/javascript" charset="utf-8"></script>
<!-- 模板引擎 -->
<script type='text/tempalte' id='tmpList'>
  {{each datas as item index}}
    <ul class="mui-table-view mui-table-view-chevron list">
        <li class="mui-table-view-cell mui-collapse">
          <a href="#" class="mui-navigate-right">
            <div class="mui-table">
                <div class="mui-table-cell mui-col-xs-10">
                  <h5 class="mui-ellipsis">
                      {{if item.isException == 1}}
                        <span class='abnormals_span'>!</span>
                      {{/if}}
                     序列：{{item.wosequence}}&nbsp;&nbsp;{{item.description}}
                  </h5>
                </div>
                <div class="mui-table-cell mui-col-xs-2 mui-text-right">
                    <span class="mui-h5">{{item.jpnum}}</span>
                </div>
            </div>
          </a>
          <ul class="mui-table-view mui-table-view-chevron padding_5">
              <p class="mui-h6 padding_15" style='padding:0 '>{{item.description}}</p>
              <li class="mui-table-view-cell">
                  <div class="mui-table">
                      <ul class="mui-table-view mui-table-view-chevron">
                          {{each item.taskImgList as ptem}}
                            <li class="mui-table-view-cell"><img src="{{ptem.description}}" /></li>
                          {{/each}}
                      </ul>
                  </div>
              </li>
              {{each item.checkResultList as utem idx}}
                {{if utem.classestype == 1}}
                  <li style='background-color:#baf9e9' class='li_style'>
                      <div class="mui-table-view-cell">
                        <div class="mui-table">
                            <div class="mui-table-cell mui-col-xs-4">
                                {{if utem.classestype == 1}}
                                  <h5 class="mui-ellipsis title_ color_1">夜班：</h5>
                                {{else if utem.classestype == 2}}
                                  <h5 class="mui-ellipsis title_ color_2">白班：</h5>
                                {{else}}
                                  <h5 class="mui-ellipsis title_">中班：</h5>
                                {{/if}}
                            </div>
                            <div class="mui-table-cell mui-col-xs-4 text_right">
                                <span onclick='cancel(this,{{index}},{{idx}})'>取消选择</span>
                            </div>
                        </div>
                      </div>
                      <div class="mui-table-view-cell">
                          <div class="mui-card-footer">
                              <div class="mui-radio">
                                  <label>良好</label>
                                  {{if utem.checkIsGood == 0}}
                                  <input type="radio" name="radio{{index}}{{idx}}" onchange='selValue(this,{{index}},{{idx}},"checkIsGood")'>
                                  {{else}}
                                  <input type="radio" name="radio{{index}}{{idx}}" checked="checked" onchange='selValue(this,{{index}},{{idx}},"checkIsGood")'>
                                  {{/if}}
                              </div>
                              <div class="mui-radio">
                                  <label>异常</label>
                                  {{if utem.checkIsException == 0}}
                                  <input type="radio" name="radio{{index}}{{idx}}" onchange='selValue(this,{{index}},{{idx}},"checkIsException")'>
                                  {{else}}
                                  <input type="radio" name="radio{{index}}{{idx}}" checked="checked" onchange='selValue(this,{{index}},{{idx}},"checkIsException")'>
                                  {{/if}}
                              </div>
                          </div>
                      </div>
                      <div class='mui-table-view-cell'>
                          <div class="mui-card-footer noneTopLine">
                              <div class="mui-radio">
                                  <label>故障开机</label>
                                  {{if utem.checkIsFaultopen == 0}}
                                  <input type="radio" name="radio{{index}}{{idx}}" onchange='selValue(this,{{index}},{{idx}},"checkIsFaultopen")'>
                                  {{else}}
                                  <input type="radio" name="radio{{index}}{{idx}}" checked="checked" onchange='selValue(this,{{index}},{{idx}},"checkIsFaultopen")'>
                                  {{/if}}
                              </div>
                              <div class="mui-radio">
                                  <label>未开机</label>
                                  {{if utem.checkIsOpen == 0}}
                                  <input type="radio" name="radio{{index}}{{idx}}" onchange='selValue(this,{{index}},{{idx}},"checkIsOpen")'>
                                  {{else}}
                                  <input type="radio" name="radio{{index}}{{idx}}" checked="checked" onchange='selValue(this,{{index}},{{idx}},"checkIsOpen")'>
                                  {{/if}}
                              </div>
                          </div>
                      </div>
                      <div class="mui-table-view-cell detail">
                        <div class="mui-col-xs-4">
                            <h5 class="mui-ellipsis">上传图片：</h5>
                        </div>
                        <ul style='background-color:transparent !important' class="no_padding no_margin detail mui-table-view mui-grid-view mui-grid-9">
                            {{each utem.checkImgList as ptem}}
                              <li class="no_border mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3" tapmode onclick="showRemotePicture(baseURL + 'downloadFile?docinfoid='+'{{ptem.docinfoid}}', '{{ptem.description}}')">
                                <img class='upload_img' src="{{ptem.src}}"/>
                              </li>
                            {{/each}}
                            <li class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3" tapmode onclick="invokePictureTaker({{index}},{{idx}})" id="liAddPhoto{{index}}{{idx}}">
                              <img src="../image/upload.png"/ style='width:100%;height:100%'>
                            </li>
                        </ul>
                      </div>
                  </li>
                {{else if utem.classestype == 2}}
                  <li style='background-color:#cdd1fb' class='li_style'>
                      <div class="mui-table-view-cell">
                        <div class="mui-table">
                            <div class="mui-table-cell mui-col-xs-4">
                                {{if utem.classestype == 1}}
                                  <h5 class="mui-ellipsis title_ color_1">夜班：</h5>
                                {{else if utem.classestype == 2}}
                                  <h5 class="mui-ellipsis title_ color_2">白班：</h5>
                                {{else}}
                                  <h5 class="mui-ellipsis title_">中班：</h5>
                                {{/if}}
                            </div>
                            <div class="mui-table-cell mui-col-xs-4 text_right">
                                <span onclick='cancel(this,{{index}},{{idx}})'>取消选择</span>
                            </div>
                        </div>
                      </div>
                      <div class="mui-table-view-cell">
                          <div class="mui-card-footer">
                              <div class="mui-radio">
                                  <label>良好</label>
                                  {{if utem.checkIsGood == 0}}
                                  <input type="radio" name="radio{{index}}{{idx}}" onchange='selValue(this,{{index}},{{idx}},"checkIsGood")'>
                                  {{else}}
                                  <input type="radio" name="radio{{index}}{{idx}}" checked="checked" onchange='selValue(this,{{index}},{{idx}},"checkIsGood")'>
                                  {{/if}}
                              </div>
                              <div class="mui-radio">
                                  <label>异常</label>
                                  {{if utem.checkIsException == 0}}
                                  <input type="radio" name="radio{{index}}{{idx}}" onchange='selValue(this,{{index}},{{idx}},"checkIsException")'>
                                  {{else}}
                                  <input type="radio" name="radio{{index}}{{idx}}" checked="checked" onchange='selValue(this,{{index}},{{idx}},"checkIsException")'>
                                  {{/if}}
                              </div>
                          </div>
                      </div>
                      <div class='mui-table-view-cell'>
                          <div class="mui-card-footer noneTopLine">
                              <div class="mui-radio">
                                  <label>故障开机</label>
                                  {{if utem.checkIsFaultopen == 0}}
                                  <input type="radio" name="radio{{index}}{{idx}}" onchange='selValue(this,{{index}},{{idx}},"checkIsFaultopen")'>
                                  {{else}}
                                  <input type="radio" name="radio{{index}}{{idx}}" checked="checked" onchange='selValue(this,{{index}},{{idx}},"checkIsFaultopen")'>
                                  {{/if}}
                              </div>
                              <div class="mui-radio">
                                  <label>未开机</label>
                                  {{if utem.checkIsOpen == 0}}
                                  <input type="radio" name="radio{{index}}{{idx}}" onchange='selValue(this,{{index}},{{idx}},"checkIsOpen")'>
                                  {{else}}
                                  <input type="radio" name="radio{{index}}{{idx}}" checked="checked" onchange='selValue(this,{{index}},{{idx}},"checkIsOpen")'>
                                  {{/if}}
                              </div>
                          </div>
                      </div>
                      <div class="mui-table-view-cell detail">
                          <div class="mui-table">
                              <div class="mui-table-cell mui-col-xs-4">
                                  <h5 class="mui-ellipsis">上传图片：</h5>
                              </div>
                          </div>
                          <ul style='background-color:transparent !important' class="mui-table-view mui-grid-view mui-grid-9 detail">
                              {{each utem.checkImgList as ptem}}
                                <li class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3" tapmode onclick="showRemotePicture(baseURL + 'downloadFile?docinfoid='+'{{ptem.docinfoid}}', '{{ptem.description}}')">
                                  <img class='upload_img' src="{{ptem.src}}"/>
                                </li>
                              {{/each}}
                              <li  class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3" tapmode onclick="invokePictureTaker({{index}},{{idx}})" id="liAddPhoto{{index}}{{idx}}">
                                <img src="../image/upload.png"/ style='width:100%;height:100%'>
                              </li>
                          </ul>
                      </div>
                  </li>
                {{else}}
                  <li style='background-color:#fbf8cd' class='li_style'>
                      <div class="mui-table-view-cell">
                        <div class="mui-table">
                            <div class="mui-table-cell mui-col-xs-4">
                                {{if utem.classestype == 1}}
                                  <h5 class="mui-ellipsis title_ color_1">夜班：</h5>
                                {{else if utem.classestype == 2}}
                                  <h5 class="mui-ellipsis title_ color_2">白班：</h5>
                                {{else}}
                                  <h5 class="mui-ellipsis title_">中班：</h5>
                                {{/if}}
                            </div>
                            <div class="mui-table-cell mui-col-xs-4 text_right">
                                <span onclick='cancel(this,{{index}},{{idx}})'>取消选择</span>
                            </div>
                        </div>
                      </div>
                      <div class="mui-table-view-cell">
                          <div class="mui-card-footer">
                              <div class="mui-radio">
                                  <label>良好</label>
                                  {{if utem.checkIsGood == 0}}
                                  <input type="radio" name="radio{{index}}{{idx}}" onchange='selValue(this,{{index}},{{idx}},"checkIsGood")'>
                                  {{else}}
                                  <input type="radio" name="radio{{index}}{{idx}}" checked="checked" onchange='selValue(this,{{index}},{{idx}},"checkIsGood")'>
                                  {{/if}}
                              </div>
                              <div class="mui-radio">
                                  <label>异常</label>
                                  {{if utem.checkIsException == 0}}
                                  <input type="radio" name="radio{{index}}{{idx}}" onchange='selValue(this,{{index}},{{idx}},"checkIsException")'>
                                  {{else}}
                                  <input type="radio" name="radio{{index}}{{idx}}" checked="checked" onchange='selValue(this,{{index}},{{idx}},"checkIsException")'>
                                  {{/if}}
                              </div>
                          </div>
                      </div>
                      <div class='mui-table-view-cell'>
                          <div class="mui-card-footer noneTopLine">
                              <div class="mui-radio">
                                  <label>故障开机</label>
                                  {{if utem.checkIsFaultopen == 0}}
                                  <input type="radio" name="radio{{index}}{{idx}}" onchange='selValue(this,{{index}},{{idx}},"checkIsFaultopen")'>
                                  {{else}}
                                  <input type="radio" name="radio{{index}}{{idx}}" checked="checked" onchange='selValue(this,{{index}},{{idx}},"checkIsFaultopen")'>
                                  {{/if}}
                              </div>
                              <div class="mui-radio">
                                  <label>未开机</label>
                                  {{if utem.checkIsOpen == 0}}
                                  <input type="radio" name="radio{{index}}{{idx}}" onchange='selValue(this,{{index}},{{idx}},"checkIsOpen")'>
                                  {{else}}
                                  <input type="radio" name="radio{{index}}{{idx}}" checked="checked" onchange='selValue(this,{{index}},{{idx}},"checkIsOpen")'>
                                  {{/if}}
                              </div>
                          </div>
                      </div>
                      <div class="mui-table-view-cell detail">
                          <div class="mui-table">
                              <div class="mui-table-cell mui-col-xs-4">
                                  <h5 class="mui-ellipsis">上传图片：</h5>
                              </div>
                          </div>
                          <ul style='background-color:transparent !important'  class="mui-table-view mui-grid-view mui-grid-9 ">
                              {{each utem.checkImgList as ptem}}
                                <li class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3" tapmode onclick="showRemotePicture(baseURL + 'downloadFile?docinfoid='+'{{ptem.docinfoid}}', '{{ptem.description}}')">
                                  <img class='upload_img' src="{{ptem.src}}"/>
                                </li>
                              {{/each}}
                              <li  class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3" tapmode onclick="invokePictureTaker({{index}},{{idx}})" id="liAddPhoto{{index}}{{idx}}">
                                <img src="../image/upload.png"/ style='width:100%;height:100%'>
                              </li>
                          </ul>
                      </div>
                  </li>
                {{/if}}
              {{/each}}
          </ul>
        </li>
    </ul>
  {{/each}}
</script>
<script type="text/javascript">
    var page = 1;
    var loadEnd = false;
    var dataList;
    var taskList;
    var mm = 0;
    var ss = 0;
    var str = '';
    var timer = null;
    var idList = []
    var flag = true
    var start,suspend,end, UILoading, UIloadId
    var ckFun = function() {
        api.setTabBarAttr({
            index: 2
        });
    }

    apiready = function() {
        UILoading = api.require('UILoading');
        onLoadData();
//      scrollToBottomHandler(function() {
//  			if (!loadEnd) { // 没有结束时继续加载
//  				page++;
//  				onLoadData(page,true);
//  			}
//  		})
        Refresh(function() {
          loadEnd = false;
          page = 1;
          onLoadData(page,false);

        });
        api.addEventListener({
  		    name:'navitembtn'
    		},function(ret, err){
    			if (!canModify()){
    				return;
    			}
          flag = true
          for (var i = 0; i < taskList.length; i++) {
            for (var j = 0;j < taskList[i].checkResultList.length; j++) {
              if (taskList[i].checkResultList[j].checkIsException == 1 && taskList[i].checkResultList[j].checkImgList.length == 0) {
                Toast('选择了异常的班次必须上传图片')
                flag = false
                break
              }
            }
            if (!flag) {
              break
            }
          }
	  	    if(ret.type == 'right' && flag){
            flag = false
	  	    	ajaxrd("saveTaskCheckPoint",{
			        checkList:taskList
			      },function(data){
              flag = true
					    Toast('保存成功');
              stopTime()
              onLoadData();
			      })
	  	    }
	  	  })
        api.parseTapmode();
    }
    function onLoadData(page,load){
      ajaxrd("queryTaskCheckPointDetail",{
       workorderid: api.pageParam.workorderid
      //  workorderid:'99470855'

      },function(data){
          api.refreshHeaderLoadDone();
          $api.text($api.byId('workorderid'), data.workorderid);
          $api.text($api.byId('description'), data.description);
          $api.text($api.byId('location'), data.location);
          $api.text($api.byId('actstart'), data.actstart);
          $api.text($api.byId('actfinish'), data.actfinish);
          $api.text($api.byId('wonum'), data.wonum);

          data.taskList.forEach(function(item){
            item.checkResultList.forEach(function(ptem){
              ptem.checkImgList.forEach(function(otem){
                otem.src = baseURL + 'downloadFile?docinfoid=' + otem.docinfoid_sl
              })
            })
          })
          AddData('tmpList','tmpDiv', data.taskList, load);
          taskList =  data.taskList
          dataList = data
          this.onStatus(data.workorderid)
          var arr = []
          //for(var item of data.imgList) {
          for(var item of data.attachList) {//modify by luohan 2019.11.17
            arr.push({
              docinfoid: item.docinfoid,
              description: item.description,
              src: baseURL + 'downloadFile?docinfoid=' + item.docinfoid_sl
            })
          }
          var html = template('tmpImgList', {datas: arr});
          $api.html($api.byId('ul_img'), html);
          if (data.taskList.length < 10) {
            loadEnd = true
          }
      })
    }

    function getTimeData () {
      str = "";
      if (++ss == 60) {
          if (++mm == 60) {
              mm = 0;
          }
          ss = 0;
      }
      str += mm < 10 ? "0" + mm : mm;
      str += ":";
      str += ss < 10 ? "0" + ss : ss;
      $api.text($api.byId('timer'), str)
    }

    function stopTime() {
      clearInterval(timer)
      mm = 0;
      ss = 0;
      str = '';
      timer = null;
      $api.text($api.byId('timer'), null)
    }

    function onStatus (workorderid) {
      ajaxrd("queryTaskCheckPointOpType",{
         workorderid: workorderid
      },function(data){
        if(data.opType == 1){
          $api.addCls($api.byId('start_btn'), 'bgc_ccc');
          $api.removeCls($api.byId('suspend_btn'), 'bgc_ccc');
          $api.removeCls($api.byId('end_btn'), 'bgc_ccc');
        }else if (data.opType == 2){
          $api.removeCls($api.byId('start_btn'), 'bgc_ccc');
          $api.addCls($api.byId('suspend_btn'), 'bgc_ccc');
          $api.removeCls($api.byId('end_btn'), 'bgc_ccc');
        }else{
          $api.removeCls($api.byId('start_btn'), 'bgc_ccc');
          $api.addCls($api.byId('suspend_btn'), 'bgc_ccc');
          $api.addCls($api.byId('end_btn'), 'bgc_ccc');
        }
      })
    }

    function common (index,idx) {
      taskList[index].checkResultList[idx].checkIsGood = 0
      taskList[index].checkResultList[idx].checkIsException = 0
      taskList[index].checkResultList[idx].checkIsFaultopen = 0
      taskList[index].checkResultList[idx].checkIsOpen = 0
    }

    function selValue(that,index,idx,str) {
      this.common(index,idx)
      switch (str) {
        case 'checkIsGood':
          taskList[index].checkResultList[idx].checkIsGood = 1
          break;
        case 'checkIsException':
          taskList[index].checkResultList[idx].checkIsException = 1
          break;
        case 'checkIsFaultopen':
          taskList[index].checkResultList[idx].checkIsFaultopen = 1
          break;
        default:
          taskList[index].checkResultList[idx].checkIsOpen = 1
      }
    }

    function onStart (that){
    	if (!canModify()){
			return;
		}
      if($api.hasCls(that, 'bgc_ccc')){
        return false
      }
      if(!timer){
        timer = setInterval(getTimeData, 1000)
      }
      this.onCheck(1)
    }

    function onSuspend (that){
    	if (!canModify()){
			return;
		}
      if($api.hasCls(that, 'bgc_ccc')){
        return false
      }
      this.onCheck(2)
      clearInterval(timer)
      timer = null;
    }

    function onEnd (that){
    	if (!canModify()){
			return;
		}
      if($api.hasCls(that, 'bgc_ccc')){
        return false
      }
      this.onCheck(3)
      this.stopTime()
    }

    function onCheck(val){
      ajaxrd("saveTaskCheckPointTime",{
        workorderid: dataList.workorderid,
        opType:val
      },function(data){
        if(data.opType == 1){
          $api.addCls($api.byId('start_btn'), 'bgc_ccc');
          $api.removeCls($api.byId('suspend_btn'), 'bgc_ccc');
          $api.removeCls($api.byId('end_btn'), 'bgc_ccc');
        }else if (data.opType == 2){
          $api.removeCls($api.byId('start_btn'), 'bgc_ccc');
          $api.addCls($api.byId('suspend_btn'), 'bgc_ccc');
          $api.removeCls($api.byId('end_btn'), 'bgc_ccc');
        }else{
          $api.removeCls($api.byId('start_btn'), 'bgc_ccc');
          $api.addCls($api.byId('suspend_btn'), 'bgc_ccc');
          $api.addCls($api.byId('end_btn'), 'bgc_ccc');
        }
      })
    }
    //调用拍照功能
    function invokePictureTaker(index,idx) {
//  	alert("index:" +index);
//  	alert("idx:" + idx);
    	if (!canModify()){
			return;
		}
        takePicture(function(localImgFile, id, id_sl) {
            //存储已拍照的照片
             taskList[index].checkResultList[idx].checkImgList.push({
               docinfoid: id,
               docinfoid_sl: id_sl
             })
            //上传成功，则将照片加到列表中
            var liAddPhoto = $api.byId('liAddPhoto' + index + idx);
            $api.before(liAddPhoto, "<li class='mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3' tapmode onclick=\"showLocalPicture('" + localImgFile + "')\">" +
                "<img class='mui-media-object' src='" + localImgFile + "'>" + "</li>");
            api.parseTapmode();
            console.log('上=='+JSON.stringify(taskList))
        });
    }

    function cancel(that,index,idx){
      var list = document.getElementsByName('radio'+index+idx)
      for(var i=0;i<list.length;i++){
        list[i].checked = false
      }
      this.common(index,idx)
    }

    String.prototype.endWith=function(endStr){
	      var d=this.length-endStr.length;
	      return (d>=0&&this.lastIndexOf(endStr)==d);
	  }

    function uploadXlsx(id,name){
		var str = name.toLocaleLowerCase()
		var index = str.lastIndexOf("\.");
		var newString = str.substring(index +1, str.length);
		if(str.endWith("doc") || str.endWith("docx") || str.endWith("xls") || str.endWith("xlsx") || str.endWith("ppt") || str.endWith("pptx")){
			showExcelFile(baseURL + 'downloadFile?docinfoid=' + id, guid()+'.'+ newString)
		}else{
			showRemotePicture(baseURL + 'downloadFile?docinfoid=' + id+'', guid()+'.'+ newString)
		}
	}
</script>

</html>
